﻿using System;
using System.Collections.Generic;


public class GameCfgData : ImplData
{

	public class GameCfg
	{
		public string gameType = "";
		public string urlVideo = "";

        public Cfg mansu = new Cfg();
        public Cfg kuaisu = new Cfg();

        public class Cfg
        {
            public float speed = 4f;
//            public List<float> gudian = new List<float>();
//            public List<float> gudian2 = new List<float>();

            public Dictionary<float, string> gudian = new Dictionary<float, string>();
            public Dictionary<float, string> gudian2 = new Dictionary<float, string>();
            public string urlMusic = "";
        }



	}

    

	private Dictionary<string, GameCfg> d = new Dictionary<string, GameCfg> ();

	protected override int Deserialize()
	{

		if (string.IsNullOrEmpty(jsonText))
			return -1;

		data = MiniJSON.Json.Deserialize(jsonText) as Dictionary<string, object>;

		foreach (var item in data) {
		
			GameCfg gamecfg = new GameCfg ();
			Dictionary<string, object> dict = item.Value as Dictionary<string, object>;
			gamecfg.gameType = dict ["type"] as string;
			gamecfg.urlVideo = dict ["urlVideo"] as string;

            // mansu
            Dictionary<string,object> dt = dict["mansu"] as Dictionary<string, object>;
            gamecfg.mansu.speed = Convert.ToSingle(dt["speed"]);
            
			gamecfg.mansu.urlMusic = dt ["urlMusic"] as string;
			Dictionary<string, object> l  = dt ["gudian"] as Dictionary<string, object>;
			foreach (var f in l) {
                gamecfg.mansu.gudian.Add(Convert.ToSingle(f.Key), f.Value as string);
			}

			Dictionary<string,object> ll  = dt ["gudian2"] as Dictionary<string, object>;
			foreach (var f in ll) {
                gamecfg.mansu.gudian2.Add(Convert.ToSingle(f.Key), f.Value as string);
			}
            // mansu end ---

            // kuaisu
            Dictionary<string, object> dt1 = dict["kuaisu"] as Dictionary<string, object>;
            gamecfg.kuaisu.speed = Convert.ToSingle(dt1["speed"]);
            gamecfg.kuaisu.urlMusic = dt1["urlMusic"] as string;
            Dictionary<string, object> lig = dt1["gudian"] as Dictionary<string, object>;
            foreach (var f in lig)
            {

                gamecfg.kuaisu.gudian.Add(Convert.ToSingle(f.Key), f.Value as string);
            }

            Dictionary<string, object> ligg = dt1["gudian2"] as Dictionary<string, object>;
            foreach (var f in ligg)
            {

                gamecfg.kuaisu.gudian2.Add(Convert.ToSingle(f.Key), f.Value as string);
            }
            // mansu end ---


            d.Add (item.Key, gamecfg);

		}
			
		return 0;
	}
		
	public GameCfg GetCfg( string id )
	{
		if (d.ContainsKey (id))
			return d [id];
		else
			return null;
	}
		

}


